import { TR_ch } from "./languages/ch";
import { TR_en } from "./languages/en";

class Language {
  constructor() {
    this.locale = LanguageEnum.CH;
    this.messages = {
      chinese: {message: TR_ch},
      english: {message: TR_en}
    }
  }

  getMessage(msgPath) {
    if (!msgPath) {
      return '';
    }
    let languageJson = this.messages[this.locale];
    return msgPath.split('.').reduce((xs, x) => (xs && xs[x]) ? xs[x] : null, languageJson) || msgPath
  }
}
export const LanguageEnum = {
  CH: 'chinese',
  EN: 'english',
}

export const language = new Language();